var Fight,
  __extends =
    (this && this.__extends) ||
    (function () {
      var t = function (e, i) {
        return (t =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (t, e) {
              t.__proto__ = e;
            }) ||
          function (t, e) {
            for (var i in e)
              Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]);
          })(e, i);
      };
      return function (e, i) {
        function o() {
          this.constructor = e;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        t(e, i),
          (e.prototype =
            null === i
              ? Object.create(i)
              : ((o.prototype = i.prototype), new o()));
      };
    })();
!(function (t) {
  var e = (function (e) {
    function i(i) {
      var o = e.call(this) || this;
      (o.bout = 0),
        (o.fightRoleList = []),
        (o.xyArray = [
          { x: 50, y: 145 },
          { x: 50, y: 215 },
          { x: 110, y: 110 },
          { x: 110, y: 180 },
          { x: 110, y: 250 },
        ]),
        (o.xyArrayOne = [{ x: 50, y: 180 }]),
        (o.xyArrayThree = [
          { x: 50, y: 145 },
          { x: 50, y: 215 },
          { x: 110, y: 180 },
        ]),
        (o.speedArray = [
          {},
          {
            one: 100,
            three: 300,
            four: 400,
            five: 500,
            six: 600,
            seven: 700,
            eight: 800,
            ten: 1e3,
            twelve: 1200,
            fourteen: 1400,
            sixteen: 1600,
          },
          {
            one: 66,
            three: 200,
            four: 266,
            five: 333,
            six: 400,
            seven: 466,
            eight: 533,
            ten: 666,
            twelve: 800,
            fourteen: 933,
            sixteen: 1066,
          },
          {
            one: 33,
            three: 100,
            four: 133,
            five: 166,
            six: 200,
            seven: 233,
            eight: 266,
            ten: 333,
            twelve: 400,
            fourteen: 466,
            sixteen: 533,
          },
          {
            one: 25,
            three: 65,
            four: 80,
            five: 100,
            six: 120,
            seven: 140,
            eight: 160,
            ten: 200,
            twelve: 240,
            fourteen: 280,
            sixteen: 320,
          },
          {
            one: 15,
            three: 40,
            four: 50,
            five: 60,
            six: 80,
            seven: 90,
            eight: 100,
            ten: 120,
            twelve: 130,
            fourteen: 140,
            sixteen: 533,
          },
          {
            one: 10,
            three: 30,
            four: 40,
            five: 50,
            six: 60,
            seven: 233,
            eight: 80,
            ten: 100,
            twelve: 120,
            fourteen: 140,
            sixteen: 160,
          },
        ]),
        (o.boutList = []),
        (o.harmFontClipTextList = []),
        (o.status = 0),
        (o.makeNum = 1),
        (o.i = 0),
        (o.magicList = []),
        (o.infoShow = !1),
        (o.margin_top = 30),
        (o.auto = !1),
        (o.onceAuto = !1),
        (o.changeRoleIng = !1),
        (o.aniSpeed = 1);
      var a = (i / 750) * 850;
      o.size(i, a);
      var s = "fight/bg_" + Utils.random(1, 10) + ".jpg",
        n = new Laya.Image(s);
      n.pos(0, (i / t.FightHeader.WIDTH) * t.FightHeader.HEIGHT),
        n.size(i, a),
        o.addChild(n),
        (o.bgImage = n);
      var h = new Laya.Sprite();
      h.pos(0, (i / t.FightHeader.WIDTH) * t.FightHeader.HEIGHT),
        h.size(i, a),
        o.addChild(h),
        (o.bgColor = h),
        (o.roleMap = {}),
        (o.roleBox = new Laya.Sprite()),
        o.addChild(o.roleBox);
      var r = new t.FightHeader(i);
      r.pos(0, 0),
        (o.header = r),
        o.roleBox.addChild(r),
        (o.select = new Laya.Sprite()),
        o.select.graphics.drawPoly(
          0,
          0,
          [0, 0, 0, 14, 10, 7],
          "#c7254e",
          "#ffffff",
          2
        ),
        (o.select.autoSize = !0),
        o.addChild(o.select),
        (o.target = new Laya.Sprite()),
        o.target.graphics.drawPoly(
          0,
          0,
          [10, 0, 10, 14, 0, 7],
          "#4387cf",
          "#ffffff",
          2
        ),
        (o.target.autoSize = !0),
        o.addChild(o.target),
        (o.magic = new t.Magic()),
        o.addChild(o.magic),
        (o.magic.visible = !1),
        (o.roleInfo = new t.RoleInfo()),
        o.addChild(o.roleInfo),
        (o.roleInfo.visible = !1),
        o.roleInfo.pos((i - t.RoleInfo.WID) / 2, (a - t.RoleInfo.HEI) / 2),
        (o.fightButton = new t.FightButton()),
        o.fightButton.pos(i / 2 - 127.5, 350),
        o.roleBox.addChild(o.fightButton),
        (o.fightGoods = new t.FightGoods(o, i));
      var l = o.xyArray[4],
        c = o.margin_top;
      return (
        (o.horseRight = new t.FightHorse()),
        o.horseRight.thePos(l.x + i / 2, l.y + c, 1),
        o.roleBox.addChild(o.horseRight),
        (o.horseLeft = new t.FightHorse()),
        o.horseLeft.thePos(-l.x + i / 2, l.y + c, -1),
        o.roleBox.addChild(o.horseLeft),
        (o.videoBtn = new Laya.Button()),
        o.videoBtn.pos(340, 6),
        o.videoBtn.size(35, 23),
        (o.videoBtn.skin = "comp/commonpic/btn_laba.png"),
        o.bgImage.addChild(o.videoBtn),
        (o.videoBtn.stateNum = 1),
        o.videoBtn.on(Laya.Event.CLICK, o, o.onVideoBtnDidClick),
        o
      );
    }
    return (
      __extends(i, e),
      (i.prototype.bind = function () {
        this.roleBox.on("FightButton", this, this.buttionClick),
          this.roleBox.on("RoleInit", this, this.progressBar),
          this.roleBox.on("selectGoods", this, this.selectGoods),
          this.roleBox.on("selectKill", this, this.selectKill),
          this.roleBox.on("selectCortege", this, this.selectCortege),
          this.select.on(Laya.Event.CLICK, this, function (t, e, i) {}),
          this.roleInfo.on(Laya.Event.CLICK, this, this.roleInfoClick),
          (this.status = 1),
          WebSocketService.addListener(
            { caller: this, code: 510, method: this.recBout },
            !0
          ),
          WebSocketService.addListener(
            { caller: this, code: 520, method: this.changeRole },
            !0
          ),
          WebSocketService.addListener(
            { caller: this, code: 590, method: this.result },
            !0
          ),
          WebSocketService.addListener(
            { caller: this, code: 505, method: this.receivefightState },
            !0
          ),
          WebSocketService.addListener(
            { caller: this, code: 502, method: this.horse },
            !0
          );
      }),
      (i.prototype.init = function (t, e, i) {
        if ((void 0 === i && (i = !0), i)) {
          this.header.setEnemyName(e.enemyName),
            (this.bout = 0),
            (this.changeRoleIng = !1),
            (this.resultMsg = null),
            (this.width = t),
            this.header.setMyName(),
            (this.fightRoleList = []),
            (this.roleMap = {});
          var o = "fight/bg_" + Utils.random(1, 10) + ".jpg";
          this.bgImage.skin = o;
          "noPlay" == laya.net.LocalStorage.getItem("playerVideo")
            ? ((this.videoBtn.gray = !0),
              (Laya.SoundManager.muted = !0),
              (this.playerVideo = !1))
            : ((this.videoBtn.gray = !1),
              (Laya.SoundManager.muted = !1),
              (this.playerVideo = !0));
          var a = "video/fight_Z" + Utils.random(1, 5) + ".mp3";
          Laya.SoundManager.playMusic(
            a,
            100,
            new Handler(this, this.onComplete)
          );
        }
        for (
          var s = t / 2, n = [], h = [], r = 0, l = e.fRInfos;
          r < l.length;
          r++
        ) {
          var c = l[r];
          c.indexID < 6 ? n.push(c) : h.push(c);
        }
        e.need_ch_ID
          ? (this.initCamp(s, 2, n), this.initCamp(s, 1, h))
          : (this.initCamp(s, 1, n), this.initCamp(s, 2, h));
      }),
      (i.prototype.onComplete = function () {
        console.log("播放完成");
      }),
      (i.prototype.initCamp = function (e, i, o) {
        var a,
          s = o.length;
        2 == i && (a = 1), 1 == i && (a = -1);
        var n,
          h,
          r = this.margin_top;
        h =
          1 == s ? this.xyArrayOne : 3 == s ? this.xyArrayThree : this.xyArray;
        for (var l, c, p, f, u = 0; u < s; u++)
          if (
            ((n = h[u]),
            (l = o[u]),
            (c = this.getId(l)),
            null == (p = this.getFightRole(c)))
          ) {
            this.changeRoleIng && this.removeOneDie(i),
              (p = Laya.Pool.getItemByClass("FightRole", t.FightRole)).setId(c),
              this.roleBox.addChild(p),
              (f = this.getAniName(l)),
              (p.side = i),
              p.thePos(n.x * a + e, n.y + r, 1 == i ? -1 : 1),
              p.init(
                f,
                i,
                l.roletype,
                l.speedStr,
                l.hp / l.maxHp,
                l.mp / l.maxMp
              ),
              p.setState(l.state),
              p.refreshBuff(),
              l.hp < 1 && p.die(),
              this.magic.loadSkill(l),
              this.fightRoleList.push(p);
            var g = new t.Role();
            g.init(l, c, i),
              (this.roleMap[c] = g),
              p.on(Laya.Event.CLICK, this, this.roleClick);
          } else
            p.thePos(n.x * a + e, n.y + r, 1 == i ? -1 : 1),
              p.pos(n.x * a + e, n.y + r),
              p.setSpeed(l.speedStr);
      }),
      (i.prototype.payAll = function () {
        for (var t = this.fightRoleList.length, e = 0; e < t; e++)
          this.fightRoleList[e].onceAction("idle");
      }),
      (i.prototype.refreshStatus = function () {
        for (var t, e, i = this.fightRoleList.length, o = 0; o < i; o++)
          (t = this.fightRoleList[o]),
            (e = this.roleMap[t.getId()]).hp <= 0
              ? ((e.hp = 0), t.die())
              : t.isDie() && t.resurgence(),
            t.isInit && t.refresh(e.hp / e.maxHp, e.mp / e.maxMp);
      }),
      (i.prototype.phyAttack = function (t, e) {
        var i = this.speedArray[this.aniSpeed],
          o = t.x,
          a = t.y,
          s = e.x,
          n = 1;
        t.x < e.x && (n = -1);
        var h = 15;
        1 == t.side && (h = -15),
          console.log(
            "timeInterval.three +++++++++++++ " + i + "    " + i.three
          ),
          Laya.Tween.to(t, { x: e.x - 25 * n + h, y: e.y }, i.three - 100),
          Laya.timer.once(i.three, t, t.payAction, ["attack"]),
          Laya.timer.once(i.five, this, function () {
            for (var t = 0, o = this.harmFontClipTextList; t < o.length; t++)
              o[t].alpha = 1;
            Laya.Tween.to(e, { x: s - 10 * n }, i.one);
          }),
          Laya.timer.once(i.six, this, function () {
            Laya.Tween.to(e, { x: s }, i.one);
          }),
          Laya.timer.once(i.seven, this, function () {
            Laya.Tween.to(t, { x: o, y: a }, i.three);
          }),
          Laya.timer.once(i.ten, this, function () {
            t.payAction("idle");
            for (var e, o = 0, a = this.harmFontClipTextList; o < a.length; o++)
              (e = a[o]), Laya.Tween.to(e, { alpha: 0 }, i.four);
          });
      }),
      (i.prototype.magicAttack = function (t, e) {
        for (
          var i,
            o,
            a = this.speedArray[this.aniSpeed],
            s = e.act_att,
            n = 0,
            h = e.roleAttChang;
          n < h.length;
          n++
        ) {
          var r = h[n];
          if (r[0] != e.attIndexID) {
            i = this.getRoleByIndex(r[0]);
            var l = (o = this.getFightRole(i.id)).getBounds().width / 2,
              c = o.getBounds().height / 2,
              p = 1;
            2 == o.side && (p = -1),
              (l *= p),
              this.createMagic().pos(o.x - l, o.y + c);
          }
        }
        t.payAction("attack"),
          Laya.timer.once(a.three, this, function () {
            t.payAction("idle");
            for (var e = 0, i = this.magicList; e < i.length; e++) {
              var o = i[e];
              o.isUsed && ((o.visible = !0), o.paySkill(s));
            }
          }),
          Laya.timer.once(a.six, this, function () {
            for (var t = 0, e = this.harmFontClipTextList; t < e.length; t++)
              e[t].alpha = 1;
          }),
          Laya.timer.once(a.ten, this, function () {
            for (var t = 0, e = this.magicList; t < e.length; t++) {
              var i = e[t];
              i.isUsed && ((i.visible = !1), (i.isUsed = !1));
            }
            for (var o, s = 0, n = this.harmFontClipTextList; s < n.length; s++)
              (o = n[s]), Laya.Tween.to(o, { alpha: 0 }, a.four);
          });
      }),
      (i.prototype.sustainAttack = function (t) {
        for (
          var e,
            i,
            o = this.speedArray[this.aniSpeed],
            a = t.act_att,
            s = 0,
            n = t.roleAttChang;
          s < n.length;
          s++
        ) {
          var h = n[s];
          e = this.getRoleByIndex(h[0]);
          var r = (i = this.getFightRole(e.id)).getBounds().width / 2,
            l = i.getBounds().height / 2,
            c = 1;
          2 == i.side && (c = -1),
            (r *= c),
            this.createMagic().pos(i.x - r, i.y + l);
        }
        Laya.timer.once(o.three, this, function () {
          for (var t = 0, e = this.magicList; t < e.length; t++) {
            var i = e[t];
            i.isUsed && ((i.visible = !0), i.paySkill(a));
          }
        }),
          Laya.timer.once(o.six, this, function () {
            for (var t = 0, e = this.harmFontClipTextList; t < e.length; t++)
              e[t].alpha = 1;
          }),
          Laya.timer.once(o.ten, this, function () {
            for (var t = 0, e = this.magicList; t < e.length; t++) {
              var i = e[t];
              i.isUsed && ((i.visible = !1), (i.isUsed = !1));
            }
            for (var a, s = 0, n = this.harmFontClipTextList; s < n.length; s++)
              (a = n[s]), Laya.Tween.to(a, { alpha: 0 }, o.four);
          });
      }),
      (i.prototype.useGoods = function (t, e) {
        var i = this.speedArray[this.aniSpeed];
        t.side,
          t.payAction("attack"),
          Laya.timer.once(i.three, this, function () {
            t.payAction("idle");
            for (var e = 0, i = this.harmFontClipTextList; e < i.length; e++)
              i[e].alpha = 1;
          }),
          Laya.timer.once(i.eight, this, function () {
            for (var t, e = 0, o = this.harmFontClipTextList; e < o.length; e++)
              (t = o[e]), Laya.Tween.to(t, { alpha: 0 }, i.four);
          });
      }),
      (i.prototype.relive = function (t) {
        for (
          var e = this.speedArray[this.aniSpeed],
            i = 0,
            o = this.harmFontClipTextList;
          i < o.length;
          i++
        )
          o[i].alpha = 1;
        Laya.timer.once(e.five, this, function () {
          for (var t, i = 0, o = this.harmFontClipTextList; i < o.length; i++)
            (t = o[i]), Laya.Tween.to(t, { alpha: 0 }, e.four);
        });
      }),
      (i.prototype.shuang = function (t, e) {
        var i = this.speedArray[this.aniSpeed];
        t.payAction("attack"),
          Laya.timer.once(i.three, this, function () {
            t.payAction("idle"),
              e.act_att_name.indexOf("开始无双") > 0 ||
              e.act_att_name.indexOf("开始觉醒") > 0
                ? t.startShuang()
                : t.stopShuang();
          });
      }),
      (i.prototype.attackByBoutLog = function (e) {
        var i = this.getRoleId(e, !0),
          o = this.getRoleId(e, !1),
          a = this.getFightRole(i),
          s = this.getFightRole(o);
        a && a.hideStatus();
        var n,
          h = this.speedArray[this.aniSpeed];
        this.roleAttChang(e);
        var r = !1,
          l = !1,
          c = this.getActName(e.act_type, e);
        if (
          1 == e.act_type ||
          12 == e.act_type ||
          11 == e.act_type ||
          13 == e.act_type ||
          14 == e.act_type
        ) {
          if (
            (this.phyAttack(a, s),
            null != e.act_att_name &&
              e.act_att_name.indexOf("眩晕") >= 0 &&
              ((r = !0), s.addBuff(512)),
            1 == e.act_type && -1 != e.content.indexOf("未中"))
          ) {
            p = "fight_duobi";
            s.addHeartVal(p, this.aniSpeed);
          } else if (11 == e.act_type) {
            p = "fight_baoji";
            s.addHeartVal(p, this.aniSpeed);
          } else if (12 == e.act_type) {
            p = "fight_zhiming";
            s.addHeartVal(p, this.aniSpeed);
          } else if (13 == e.act_type) {
            p = "fight_fanji";
            s.addHeartVal(p, this.aniSpeed);
          } else if (14 == e.act_type) {
            p = "fight_fanzhen";
            s.addHeartVal(p, this.aniSpeed);
          }
          n = h.fourteen;
        } else if (2 == e.act_type || 20 == e.act_type) {
          if (20 == e.act_type) {
            var p = "fight_fabao";
            s.addHeartVal(p, this.aniSpeed);
          }
          this.drawBg(),
            (l = !0),
            (r = t.FightBuff.isBuff(e.act_att)),
            this.magicAttack(a, e),
            null != e.act_att_name &&
              e.act_att_name.indexOf("眩目") >= 0 &&
              ((r = !0), s.addBuff(512)),
            (n = h.fourteen);
        } else
          9 == e.act_type
            ? ((e.act_att = 14), this.sustainAttack(e), (n = h.fourteen))
            : 3 == e.act_type
            ? "复活" == e.act_att_name ||
              "吸血" == e.act_att_name ||
              "吸法" == e.act_att_name
              ? (this.relive(s), (n = h.twelve), (c = e.act_att_name))
              : (this.useGoods(a, s), (n = h.fourteen), (c = e.act_att_name))
            : 8 == e.act_type
            ? (this.shuang(a, e), (n = h.twelve), (c = e.act_att_name))
            : (6 != e.act_type && 17 != e.act_type) ||
              (this.useGoods(a, s), (n = h.twelve), (c = e.act_att_name));
        this.header.setToast(c, this.aniSpeed),
          Laya.timer.once(h.six, this, this.refreshStatus),
          Laya.timer.once(n, this, this.attackEnd, [i, o, r, l]);
      }),
      (i.prototype.attackEnd = function (t, e, i, o) {
        if ((this.getFightRole(t).showStatus(), i)) {
          var a = this.getFightRole(e);
          a && a.refreshBuff();
        }
        for (var s = 0, n = this.harmFontClipTextList; s < n.length; s++) {
          n[s].visible = !1;
        }
        this.clearBg(), this.boutFight();
      }),
      (i.prototype.active = function (t) {
        this.select.pos(t.x - 3, t.y + 28);
      }),
      (i.prototype.activeTarget = function (t) {
        var e = this.roleMap[t.getId()];
        null != e &&
          (this.target.graphics.clear(),
          e.index < 6
            ? this.target.graphics.drawPoly(
                0,
                0,
                [10, 0, 10, 14, 0, 7],
                "#4387cf",
                "#ffffff",
                2
              )
            : this.target.graphics.drawPoly(
                0,
                0,
                [0, 0, 0, 14, 10, 7],
                "#4387cf",
                "#ffffff",
                2
              ),
          (this.target.visible = !0),
          this.target.pos(t.x - 5, t.y + 28));
      }),
      (i.prototype.getFightRole = function (t) {
        var e = null;
        return (
          this.fightRoleList.forEach(function (i) {
            i.getId() == t && (e = i);
          }),
          e
        );
      }),
      (i.prototype.roleClick = function (t) {
        if (1 != this.status && 2 == this.status) {
          var e = this.makeBout;
          if (null == e) return;
          if ("flee" == t || "defense" == t || "summon" == t) e.toId = e.fromId;
          else if ("timeout" == t);
          else if ("roleInfo" == t)
            (this.roleInfo.visible = !1), (this.target.visible = !1);
          else {
            o = t.target.getId();
            if (0 != e.type) {
              var i = this.roleMap[o];
              if (null != i && i.type != e.type) return;
            }
            if (e.toId != o)
              return (
                (e.toId = o),
                this.activeTarget(t.target),
                void this.showRoleInfo(o)
              );
            (this.roleInfo.visible = !1), (this.target.visible = !1);
          }
          if (this.auto || this.onceAuto || "timeout" == t) {
            var o;
            null != (o = this.getRoleAlive(1)) && (e.toId = o),
              "" != e.toId && (this.roleInfo.visible = !1);
          }
          return (
            0 == e.action && (e.action = 1),
            this.sendBout(),
            this.makeNum++,
            this.makeNum > 5 ? void this.beginFight(!0) : void this.make()
          );
        }
      }),
      (i.prototype.make = function () {
        var e,
          i = this.fightRoleList.length,
          o = !0;
        for (this.fightButton.clearSel(); this.i < i; )
          if (((e = this.fightRoleList[this.i]), this.i++, 2 == e.side)) {
            var a = this.roleMap[e.getId()];
            if (!e.isDie() || 2 != a.objType) {
              this.fightButton.reset(a.objType, e.getState()),
                this.active(e),
                (this.makeBout = Laya.Pool.getItemByClass(
                  "makeBout",
                  t.MakeBout
                )),
                this.makeBout.init(e.getId()),
                (o = !1);
              break;
            }
          }
        this.i == i && o && (this.beginFight(!0), (this.onceAuto = !1)),
          (!this.auto && !this.onceAuto) || o || this.roleClick("timeout");
      }),
      (i.prototype.refreshAllState = function () {
        for (var t = 0, e = this.fightRoleList; t < e.length; t++) {
          var i = e[t];
          i.getState() >= 512 && i.removeBuff(512),
            i.refreshBuff(),
            i.resetPos();
        }
      }),
      (i.prototype.boutFight = function () {
        if (this.boutList.length == this.i)
          return (
            (this.boutList = []), this.refreshAllState(), void this.startMake()
          );
        var t = this.boutList[this.i];
        if (
          (this.i++,
          16 == t.act_type ||
            18 == t.act_type ||
            4 == t.act_type ||
            19 == t.act_type ||
            7 == t.act_type ||
            15 == t.act_type)
        ) {
          var e = this.speedArray[this.aniSpeed];
          this.header.setToast(t.act_att_name, this.aniSpeed),
            Laya.timer.once(e.sixteen, this, this.boutFight);
        } else if (30 == t.act_type || 31 == t.act_type || 32 == t.act_type)
          this.boutFight();
        else if (5 == t.act_type) this.boutFight();
        else if (6 == t.act_type) {
          t.act_att_name = "成功" + t.act_att_name;
          var i = this.getRoleId(t, !1);
          (this.roleMap[i].hp = 0), this.attackByBoutLog(t);
        } else this.attackByBoutLog(t);
      }),
      (i.prototype.beginFight = function (t) {
        void 0 === t && (t = !1),
          (this.status = 0),
          this.header.setText("等待出招"),
          (this.select.visible = !1),
          (this.target.visible = !1),
          this.fightButton.changeShow(!1),
          (this.roleInfo.visible = !1),
          (this.i = 0),
          Laya.timer.loop(5e3, this, this.synFightState);
      }),
      (i.prototype.buttionClick = function (t) {
        if (
          ("attack" == t && (this.selectTagert(1), (this.makeBout.action = 1)),
          "skill" == t)
        ) {
          var e = this.roleMap[this.makeBout.fromId];
          this.fightGoods.open(t),
            this.fightGoods.setKillList(e.skill),
            (this.makeBout.action = 2);
        }
        if (
          ("goods" == t &&
            (this.fightGoods.open(t), (this.makeBout.action = 3)),
          "flee" == t && ((this.makeBout.action = 4), this.roleClick(t)),
          "catch" == t &&
            ((this.makeBout.action = 6),
            (this.makeBout.type = 1),
            this.selectTagert(1)),
          "summon" == t &&
            (this.fightGoods.open(t), (this.makeBout.action = 7)),
          "defense" == t && ((this.makeBout.action = 5), this.roleClick(t)),
          "auto" == t &&
            ((this.auto = !this.auto),
            2 == this.status &&
              ((this.makeBout.action = 1), this.roleClick("timeout"))),
          "timeout" == t &&
            2 == this.status &&
            ((this.onceAuto = !0), this.roleClick("timeout")),
          "speed" == t)
        ) {
          var i = 1;
          Global.roleVip >= 3 && (i = 2),
            Global.roleVip >= 5 && (i = 3),
            Global.roleVip >= 7 && (i = 4),
            Global.roleVip >= 8 && (i = 5),
            Global.roleVip >= 9 && (i = 6),
            this.aniSpeed == i
              ? (this.aniSpeed = 1)
              : (this.aniSpeed = this.aniSpeed + 1);
        }
      }),
      (i.prototype.startMake = function () {
        var t = this;
        if ((this.fightButton.initSpeedBtn(), this.checkFightRoleInit())) {
          if (1 == this.status) {
            if (((this.status = 2), null != this.resultMsg))
              return void this.result(this.resultMsg);
            (this.bout = this.bout + 1),
              this.header.setTime(60),
              this.header.setRound(this.bout),
              (this.select.visible = !0),
              (this.i = 0),
              (this.makeNum = 1),
              this.make(),
              this.auto || this.fightButton.show();
          }
        } else
          setTimeout(function (e) {
            return t.startMake();
          }, 300);
      }),
      (i.prototype.startMakeWithAuto = function (t) {
        var e = this;
        if (this.checkFightRoleInit()) {
          if (1 == this.status) {
            if (((this.status = 2), null != this.resultMsg))
              return void this.result(this.resultMsg);
            (this.bout = this.bout + 1),
              this.header.setTime(60),
              this.header.setRound(this.bout),
              (this.select.visible = !0),
              (this.i = 0),
              (this.makeNum = 1),
              this.make(),
              this.auto || this.fightButton.show(),
              this.fightButton.hiden(),
              (this.makeBout.action = 1),
              (this.auto = !0),
              this.roleClick("timeout");
            var i = AutoStopView.show(t, this, this.onStopAutoMethod);
            i.pos(0.5 * (Laya.stage.width - 150), 330), Laya.stage.addChild(i);
          }
        } else
          setTimeout(function (i) {
            return e.startMakeWithAuto(t);
          }, 300);
      }),
      (i.prototype.onStopAutoMethod = function () {
        AutoStopView.hide(), (this.auto = !1);
      }),
      (i.prototype.onLoad = function () {}),
      (i.prototype.getId = function (t) {
        return t.obj_type + "_" + t.role_id;
      }),
      (i.prototype.getRoleId = function (t, e) {
        return e
          ? 0 == t.attObjectType
            ? "0_" + t.attIndexID
            : t.attObjectType + "_" + t.attId
          : 0 == t.recObjectType
          ? "0_" + t.recIndexID
          : t.recObjectType + "_" + t.recId;
      }),
      (i.prototype.checkFightRoleInit = function () {
        for (var t = this.fightRoleList, e = t.length, i = 0; i < e; i++)
          if (!t[i].isInit) return !1;
        return !0;
      }),
      (i.prototype.sendBout = function () {
        var t = this.roleMap[this.makeBout.toId];
        WebSocketService.send({
          c: 508,
          d: {
            attObject: t.roleId,
            attObjectType: t.objType,
            atttype: this.makeBout.action,
            attid: this.makeBout.value,
          },
        });
      }),
      (i.prototype.recBout = function (t) {
        Laya.timer.clear(this, this.synFightState), (this.status = 1);
        var e = t.list;
        null != e && (this.boutList = e);
        var i = t.fRInfos;
        if (null != i && i.length > 0)
          for (var o = void 0, a = void 0, s = 0, n = i; s < n.length; s++) {
            var h = n[s];
            (o = this.getRoleByIndex(h.indexID)) &&
              (a = this.getFightRole(o.id)) &&
              a.setState(h.state);
          }
        this.header.setText("战斗"), (this.i = 0), this.boutFight();
      }),
      (i.prototype.showRoleInfo = function (t) {
        var e = this.roleMap[t];
        if (null != e) {
          var i = this.makeBout,
            o = "普通攻击";
          (2 != i.action && 3 != i.action) || (i.name && (o = i.name)),
            6 == i.action && (o = "招降"),
            this.roleInfo.init(o, e),
            (this.roleInfo.visible = !0);
        }
      }),
      (i.prototype.changeRole = function (t) {
        (this.changeRoleIng = !0),
          this.init(this.width, t, !1),
          (this.changeRoleIng = !1),
          this.payAll();
      }),
      (i.prototype.selectGoods = function (t, e) {
        (this.makeBout.value = t),
          (this.makeBout.name = e),
          (this.makeBout.type = 2),
          this.roleInfo.visible && this.roleInfo.changeAtk(e),
          this.selectTagert(2);
      }),
      (i.prototype.selectKill = function (t, e) {
        (this.makeBout.value = t),
          (this.makeBout.name = e),
          this.roleInfo.visible && this.roleInfo.changeAtk(e);
        var i = Dictionary.skill[t];
        i && ((this.makeBout.type = i.side), this.selectTagert(i.side));
      }),
      (i.prototype.selectCortege = function (t, e) {
        (this.makeBout.value = t),
          (this.makeBout.name = e),
          this.roleClick("summon");
      }),
      (i.prototype.result = function (t) {
        if (1 != this.status) {
          var e, i;
          if (1 == t.isWin) {
            if (((e = ""), t.fRInfos))
              for (var o = 0, a = t.fRInfos; o < a.length; o++) {
                if (6 == (l = a[o]).indexID) e += "主将";
                else {
                  if (!(i = this.getRoleByIndex(l.indexID))) continue;
                  e += i.name;
                }
                e += "获得" + l.exp + "经验\n";
              }
            if (t.msgList)
              for (var s = 0, n = t.msgList; s < n.length; s++) {
                e += (l = n[s]) + "\n";
              }
            CombatResultDialog.showCombatResultView("success", e);
          } else {
            if (((e = ""), t.msgList))
              for (var h = 0, r = t.msgList; h < r.length; h++) {
                var l = r[h];
                e += l + "\n";
              }
            CombatResultDialog.showCombatResultView("faile", e);
          }
          t.msgList &&
            (Laya.stage.event("GameMainView", "update_task_view"),
            Laya.stage.event("HomePageView", "update_task_view")),
            Laya.timer.clear(this, this.synFightState),
            Laya.timer.once(2e3, this, this.removeSelf),
            Laya.timer.once(1500, this, this.onFinshFight),
            Laya.stage.event("GameMainView", "site"),
            Laya.stage.event("GameMainView", "exp"),
            Laya.stage.event("HomePageView", "site"),
            Laya.stage.event("HomePageView", "exp"),
            this.closeFun();
        } else this.resultMsg = t;
      }),
      (i.prototype.onFinshFight = function () {
        (Laya.SoundManager.muted = !1), Laya.SoundManager.stopMusic();
      }),
      (i.prototype.getAniName = function (t) {
        if (0 == t.obj_type || 2 == t.obj_type) {
          if (t.img && t.img.indexOf("jpg") < 0 && t.img.indexOf("jpg") < 0)
            return t.img;
          if (t.roletype % 10 == 1) return "gongbing";
          if (t.roletype % 10 == 2) return "dunbing";
          if (t.roletype % 10 == 3) return "qiangbing";
        } else {
          if (t.roletype % 10 == 1 && 0 == t.sex) return "womanwu";
          if (t.roletype % 10 == 1 && 1 == t.sex) return "manwu";
          if (t.roletype % 10 == 2 && 0 == t.sex) return "womanwen";
          if (t.roletype % 10 == 2 && 1 == t.sex) return "manwen";
          if (t.roletype % 10 == 3 && 0 == t.sex) return "womanyi";
          if (t.roletype % 10 == 3 && 1 == t.sex) return "manyi";
        }
      }),
      (i.prototype.getRoleByIndex = function (t) {
        var e = this.roleMap;
        for (var i in e) if (e[i].index == t) return e[i];
      }),
      (i.prototype.getRoleAlive = function (t) {
        var e = this.roleMap;
        for (var i in e) if (e[i].type == t && e[i].hp > 0) return e[i].id;
        return null;
      }),
      (i.prototype.selectTagert = function (t) {
        var e = this.getRoleAlive(t);
        if (null != e) {
          var i = this.getFightRole(e);
          null != i &&
            (this.activeTarget(i),
            this.showRoleInfo(e),
            (this.makeBout.toId = e));
        }
      }),
      (i.prototype.createMagic = function () {
        for (var e = this.magicList, i = 0, o = e; i < o.length; i++) {
          var a = o[i];
          if (!a.isUsed) return (a.isUsed = !0), a;
        }
        var s = new t.Magic();
        return (
          (s.visible = !1), (s.isUsed = !0), this.addChild(s), e.push(s), s
        );
      }),
      (i.prototype.createFontClipText = function (t) {
        for (
          var e,
            i = this.harmFontClipTextList,
            o = "comp/fontClip_num".concat(t, ".png"),
            a = 0;
          a < i.length;
          a++
        )
          if (!(e = i[a]).visible) return (e.visible = !0), (e.skin = o), e;
        return (
          (e = new Laya.FontClip(o, "-0123456789")),
          i.push(e),
          this.addChild(e),
          e
        );
      }),
      (i.prototype.getActName = function (t, e) {
        var i = t;
        if (
          (1 == t &&
            ((null != (i = e.act_att_name) && "" != i) || (i = "普通攻击")),
          9 == t && (i = "流血" == e.act_att_name ? "流血" : "罪恶毒心"),
          11 == t &&
            ((null != (i = e.act_att_name) && "" != i) || (i = "暴击")),
          12 == t &&
            ((null != (i = e.act_att_name) && "" != i) || (i = "致命打击")),
          13 == t && (i = "反击"),
          14 == t &&
            ((null != (i = e.act_att_name) && "" != i) || (i = "反震")),
          2 == t || 20 == t)
        )
          if (20 == t) i = e.act_att_name;
          else {
            var o = e.act_att;
            i = Dictionary.skill[o].name;
          }
        return 3 == t && (i = "使用物品"), i;
      }),
      (i.prototype.roleAttChang = function (t) {
        var e,
          i,
          o = t.roleAttChang;
        if (o)
          for (var a, s = 1, n = 0, h = o; n < h.length; n++) {
            var r = h[n];
            if (0 != r[1] || 0 != r[2]) {
              if (
                ((e = this.getRoleByIndex(r[0])),
                (i = this.getFightRole(e.id)),
                (a = 0 != r[1] && 0 != r[2] ? 2 : 1),
                (s = 2 == i.side ? 27 : -27),
                0 != r[1])
              ) {
                (e.hp = e.hp + r[1]), e.hp > e.maxHp && (e.hp = e.maxHp);
                p = 1;
                r[1] > 0 && (p = 4);
                var l = this.createFontClipText(p),
                  c = r[1] + "";
                (l.value = c), l.pos(i.x + s - 6.5 * c.length, i.y - 15 - 4);
              }
              if (0 != r[2]) {
                (e.mp = e.mp + r[2]), e.mp > e.maxMp && (e.mp = e.maxMp);
                var p = 2;
                r[2] > 0 && (p = 3);
                var l = this.createFontClipText(p),
                  c = r[2] + "";
                (l.value = c),
                  l.pos(i.x + s - 6.5 * c.length, i.y - 15 * a - 4);
              }
            }
          }
      }),
      (i.prototype.roleInfoClick = function () {
        this.roleClick("roleInfo");
      }),
      (i.prototype.progressBar = function (t) {
        for (
          var e = this.fightRoleList, i = 0, o = 0, a = e;
          o < a.length;
          o++
        ) {
          a[o].isInit && i++;
        }
        AXProgressBarView.onLoadedRecourse(i / e.length);
      }),
      (i.prototype.synFightState = function () {
        WebSocketService.send({ c: 505 });
      }),
      (i.prototype.receivefightState = function (t) {
        console.log("receivefightState:" + t.sec),
          1 == t.type &&
            1 == this.status &&
            Laya.timer.clear(this, this.synFightState),
          t.type;
      }),
      (i.prototype.removeOneDie = function (t) {
        for (
          var e = this.fightRoleList, i = e.length, o = null, a = 0;
          a < i;
          a++
        ) {
          var s = e[a];
          if (s.side == t && s.isDie()) {
            o = s;
            break;
          }
        }
        if (null != o) {
          var n = e.indexOf(o);
          e.splice(n, 1),
            o.stopPlay(),
            o.removeSelf(),
            delete this.roleMap[o.getId()],
            Laya.Pool.recover("FightRole", o);
        }
      }),
      (i.prototype.horse = function (t) {
        this.margin_top;
        t.horse1
          ? (this.horseRight.init(t.horse1),
            (this.horseRight.visible = !0),
            this.horseRight.onceAction("idle"))
          : (this.horseRight.visible = !1),
          t.horse2
            ? (this.horseLeft.init(t.horse2),
              (this.horseLeft.visible = !0),
              this.horseLeft.onceAction("idle"))
            : (this.horseLeft.visible = !1);
      }),
      (i.prototype.closeFun = function () {
        (this.status = 1),
          (this.auto = !1),
          this.fightButton.resetAuto(),
          this.horseLeft.stopPlay(),
          this.horseRight.stopPlay();
        for (var t = this.fightRoleList, e = (t.length, t.pop()); e; )
          e.stopPlay(), Laya.Pool.recover("FightRole", e), (e = t.pop());
        this.fightGoods.closeDialog();
      }),
      (i.prototype.drawBg = function () {
        this.bgColor.graphics.drawRect(
          0,
          0,
          this.width,
          this.height,
          "#000000"
        );
      }),
      (i.prototype.clearBg = function () {
        this.bgColor.graphics.clear();
      }),
      (i.prototype.onVideoBtnDidClick = function (t) {
        Laya.SoundManager.muted = this.playerVideo;
        var e = t.target;
        if (this.playerVideo)
          (this.playerVideo = !1),
            (e.gray = !0),
            localStorage.setItem("playerVideo", "noPlay");
        else {
          (this.playerVideo = !0),
            (e.gray = !1),
            localStorage.setItem("playerVideo", "canPlay");
          var i = "video/fight_Z" + Utils.random(1, 5) + ".mp3";
          Laya.SoundManager.playMusic(
            i,
            100,
            new Handler(this, this.onComplete)
          );
        }
      }),
      i
    );
  })(Laya.Sprite);
  t.BoutFight = e;
})(Fight || (Fight = {}));
